<template>
  <div style="padding: 5px;">
    <!-- 显示当日借阅率 -->
    <div style="margin: 10px 0;">
      <el-card>
        <div slot="header" class="clearfix">
          <span>当日借阅率</span>
        </div>
        <div>
          <el-progress :percentage="todayBorrowRate * 100" />
          <p>{{ (todayBorrowRate * 100).toFixed(2) }}%</p>
        </div>
      </el-card>
    </div>
    <!-- 其他内容 -->
  </div>
</template>

<script>
import request from "../../utils/request";
import { ref } from 'vue';

export default {
  name: 'HomeView',
  data() {
    return {
      todayBorrowRate: 0
    };
  },
  created() {
    this.loadTodayBorrowRate();
  },
  methods: {
    loadTodayBorrowRate() {
      request.get('/borrow/todayBorrowRate')
          .then(res => {
            if (res.code === '200') {
              this.todayBorrowRate = res.data;
            }
          })
          .catch(error => {
            console.error('Error fetching today borrow rate:', error);
          });
    }
  }
};
</script>